package com.yjs.houtai.controller;

import com.yjs.houtai.entity.Goods;
import com.yjs.houtai.entity.Message;
import com.yjs.houtai.service.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@ResponseBody
@Api(tags = "商品类型")
@RestController
@RequestMapping("/api/goods")
public class GoodsController {
    @Resource
    private GoodsService goodsService;

    @ApiOperation(value="增加商品")
    @PostMapping("/insert")
    public Message insertSelective(Goods goods)
    {
        return goodsService.insertSelective(goods);
    }

    @ApiOperation(value="删除商品")
    @DeleteMapping("/delete")
    public Message deleteByPrimaryKey(int goodsId){
        return goodsService.deleteByPrimaryKey(goodsId);
    }

    @ApiOperation(value="修改商品信息")
    @PutMapping("/update")
    public Message updateByPrimaryKeySelective(Goods goods)
    {
        return goodsService.updateByPrimaryKeySelective(goods);
    }

    @ApiOperation(value="查询商品信息")
    @GetMapping("/select")
    public Message selectByPrimaryKey(int goodsId)
    {

        return goodsService.selectByPrimaryKey(goodsId);
    }

    @ApiOperation(value="查询所有商品")
    @GetMapping("/selectAll")
    public Message selectAll(){
        return goodsService.selectAll();
    }
}
